package com.preserve.core.utils;

import javax.servlet.http.HttpServletRequest;

import org.apache.shiro.SecurityUtils;

import com.preserve.common.authentication.realm.BaseShiroRealm.PreserveUser;

public class UserUtil {

	public static PreserveUser getUser(HttpServletRequest request) {
		PreserveUser preserveUser = (PreserveUser) SecurityUtils.getSubject()
				.getPrincipal();
		return preserveUser;
	}

	public static String getUserLoginName(HttpServletRequest request) {
		return getUser(request).getLoginName();
	}

	public static String getUserNiceName(HttpServletRequest request) {
		return getUser(request).getNicename();
	}
}
